home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
dfs1
/
dfs1.c
next >
Wrap
Text File
|
1993-07-08
|
5KB
|
229 lines
/* */
/* 12dot font test 1992-12-28 */
/* */
#include <string.h>
#include <egb.h>
#include <mos.h>
#include <fmcfrb.h>
#include <stdio.h>
#include <stdlib.h>
#include <sidework.h>
#include <snd.h>
#include <smsg.h>
#include <dos.h>
#include <msdos.cf>
#define iskanji(c) ((0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xfc))
static unsigned short fontSeg,dataSeg;
#define BACK 15
#define PANT 8
#define EgbParaSize 64
#define TRUE 1
#define FALSE 0
char SND_work[0x4000];
char EGB_work[4096];
char EGB_para[EgbParaSize];
char MOS_work[MosWorkSize];
int type=0,strt=0,endt=0,sw=0;
char buf[1024],buf2[1024],pat_work[258];
void rectangle(int x1, int y1, int x2, int y2)
{
WORD(EGB_para + 0) = x1;
WORD(EGB_para + 2) = y1;
WORD(EGB_para + 4) = x2;
WORD(EGB_para + 6) = y2;
EGB_rectangle(EGB_work, EGB_para);
}
int wait_click()
{
int b,x,y;
MOS_disp(1);
b = 0;
while(b == 0){
MOS_rdpos(&b,&x,&y);
if(b == 2){
sdk_invoke();
b = 0;
}
}
MOS_disp(0);
return b;
}
static unsigned short sjis2jis(unsigned short chr)
{
int ch,cl;
ch = (chr >> 8) & 0xff; cl = chr & 0xff;
ch -= ( ch <= 0x9f) ? 0x71 : 0xb1;
ch = (ch << 1)+1;
if ( cl > 0x7f ) cl--;
if ( cl >= 0x9e ) {
cl -= 0x7d;
ch++;
} else {
cl -= 0x1f;
}
return (unsigned short)(ch << 8 | cl);
}
static void font_init()
{
fontSeg = mma_allocSeg("FONT");
dataSeg = sdk_getDS();
}
static void font_end()
{
mma_freeSeg(fontSeg);
}
static int font_getSjisKanji(unsigned short s,char *buf)
{
unsigned short j,jh,jl;
unsigned int ofst;
j = sjis2jis(s);
if (j > 0x4fff) return -1; /* 2水漢字はダメ */
jh = j >> 8;
jl = j & 0xff;
ofst = ((jh-0x21)*94+jl-0x21)*24+0xc00;
_movedata(fontSeg,ofst,dataSeg,(unsigned int)buf,24);
return 0;
}
static void font_getAnk(char c,char *buf)
{
unsigned int ofst;
ofst = c*12;
_movedata(fontSeg,ofst,dataSeg,(unsigned int)buf,12);
}
static void font_put(int x,int y,char *str)
{
char buf[24];
char para[9] = {0};
int i;
if (str == NULL) return;
WORD(¶[0]) = x;
WORD(¶[2]) = y+12;
WORD(¶[4]) = 0;
EGB_sjisString(EGB_work,para);/* 位置決め */
while (*str != 0) {
if (iskanji(*str)) {
WORD(¶[6]) = *(unsigned short *)str;
i = font_getSjisKanji(((*str++ << 8) + *str++),buf);
if (i == 0) {/*1水漢字*/
EGB_textZoom(EGB_work,1,16,12);
EGB_anyChar(EGB_work,16,12,buf);
} else {/*2水漢字*/
EGB_textZoom(EGB_work,1,12,12);
WORD(¶[4]) = 2;
EGB_sjisString(EGB_work,para);
WORD(¶[4]) = 0;
}
WORD(¶[0]) += 12;
} else {
font_getAnk(*str++,buf);
EGB_textZoom(EGB_work,1,8,12);
EGB_anyChar(EGB_work,8,12,buf);
WORD(¶[0]) += 6;
}
EGB_sjisString(EGB_work,para);/* 位置決め */
}
}
void main(int argc,char *argv[])
{
char spr[200];
long avi_cls,cls_drv,byt_sec,sec_cls,cls_siz,mega=0L;
int drv,id,y=90;
EGB_resolution( EGB_work,0,0x43 );
EGB_resolution( EGB_work,1,0x43 );
EGB_color(EGB_work, 2, BACK);
EGB_paintMode(EGB_work, 0x22);
MOS_start(MOS_work, MosWorkSize);
MOS_resolution(1,3);
MOS_writePage(1);
MOS_setpos(80,90);
MOS_color(0,15);
MOS_typeRom(82,0,0,pat_work);
MOS_disp(1);
SND_init(SND_work);
SND_elevol_mute(0x01);
SMSG_open(SND_work);
EGB_color(EGB_work, 0, PANT);
rectangle(79, 89, 561, 391);
EGB_color(EGB_work, 0, PANT);
font_init() ;
FM_SetVector();
sprintf(spr," ドライブ空き容量一覧 DFS1.EXP Copyright 1993 (c) Rassyai");
font_put(81,y,spr);
y+=12;
sprintf(spr,"ドライブ 合計 空き");
font_put(81,y,spr);
for(drv = (argc==1 ? 1:atoi(argv[1]));drv<26;drv++){
if(drv == 15) break;
Registers.AX.LH.H = 0x36;
Registers.DX.R = drv;
calldos();
if(Registers.AX.R == 0xFFFF) continue;
avi_cls = (long)Registers.BX.R;
cls_drv = (long)Registers.DX.R;
byt_sec = (long)Registers.CX.R;
sec_cls = (long)Registers.AX.R;
cls_siz = sec_cls * byt_sec;
sprintf(spr,"%c: %9ldバイト(%7ldKB) %9ldバイト(%7ldKB)[%3ld%%USED]",'A' + drv - 1,
cls_drv * cls_siz,(cls_drv * cls_siz)/1024,
avi_cls * cls_siz,(avi_cls * cls_siz)/1024,
100 - (avi_cls * cls_siz /1024 * 100)/(cls_drv * cls_siz / 1024));
mega += (avi_cls * cls_siz)/1024;
y += 12;
font_put(81,y,spr);
}
sprintf(spr," 約%5ld Kバイトが使用可能です。 マウス左ボタンを押して下さい。",mega);
y += 12;
font_put(81,y,spr);
FM_ResetVector();
font_end() ;
id = SMSG_CHIME;
SMSG_play(id, 0);
MOS_typeRom(125,0,0,pat_work);
wait_click();
SND_pcm_play_rom(71,62,127,5);
SMSG_close();
SND_end();
MOS_end();
exit(0);
}